<?php

/**
 * Article form.
 *
 * @package    wills
 * @subpackage form
 * @author     Your name here
 * @version    SVN: $Id: sfDoctrineFormTemplate.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class ArticleForm extends BaseArticleForm
{
  public function configure()
  {
	unset(
      $this['created_at'], 
      $this['updated_at']
    );
	sfConfig::set('app_ckfinder_active', true);

	$this->widgetSchema['content'] = new sfWidgetFormCKEditor();

    $this->widgetSchema['special_id'] = new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('special'), 'add_empty' => '请选择专题，可不选'));
	$this->validatorSchema['title']->setMessage('required', '请填写标题');
	$this->validatorSchema['content']->setMessage('required', '请填写正文');
	$this->validatorSchema['content'] = new sfValidatorString(array('max_length' => 100000));
	$this->widgetSchema['title'] = new sfWidgetFormInputText();
	$this->widgetSchema['attachment'] = new sfWidgetFormInputFile();
   
	
	$this->widgetSchema['attachment'] = new sfWidgetFormInputFile();
    $this->validatorSchema['attachment'] = new sfValidatorFile(array(
      'max_size' => 2 *1024 * 1024,
      'path' => Wills::getUploadDirByWebPath(sfConfig::get('app_path_attachment_files')),
	  'required' => false,
	  'validated_file_class' => 'CustomValidatedFile'
    ));
	$this->validatorSchema['attachment']->setMessage('max_size', '最大2M');


	$this->widgetSchema['attachment'] = new sfWidgetFormInputFileEditable(array(
      'edit_mode' => !$this->isNew(),
      'file_src' => sprintf($this->getObject()->getAttachment()),
      'with_delete' => false
    ));
  }
}
